package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.mapper.DtsFootprintMapper;
import com.qf.pojo.DtsCollect;
import com.qf.pojo.DtsFootprint;
import com.qf.service.DtsAdminFootprintService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
public class DtsAdminFootprintServiceImpl implements DtsAdminFootprintService {

    @Autowired
    DtsFootprintMapper footprintMapper;

    @Override
    public IPage<DtsFootprint> queryPage(Integer page, Integer limit, String sort, String order, Integer goodId, Integer userId) {
        IPage<DtsFootprint> iPage = new Page<>(page,limit);
        QueryWrapper<DtsFootprint> qw = new QueryWrapper<>();
        if(!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)){
            if(order.equalsIgnoreCase("desc")){
                qw.orderByDesc(sort);
            }else{
                qw.orderByAsc(sort);
            }
        }

        if(goodId != null){
            qw.eq("goods_id",goodId);
        }
        if(userId != null){
            qw.eq("user_id",userId);
        }
        footprintMapper.selectPage(iPage,qw);
        return iPage;
    }
}
